
#import <Foundation/Foundation.h>
#import "Common.h"


@interface Renderer : NSObject{

@private
	/*
	 *	Этот кусок кода я взял из примера по OpenGL для iPhone-а.
	 */
	
    EAGLContext *glContext;
	CAEAGLLayer	*glLayer;
	
    /* The pixel dimensions of the backbuffer */
    GLint backingWidth;
    GLint backingHeight;

    /* OpenGL names for the renderbuffer and framebuffers used to render to this view */
    GLuint renderBuffer, frameBuffer;
    
    /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
    GLuint depthBuffer;
	
	Camera *activeCamera;
	int		pushTransformCount;
	
	ColorRGBA	clearColor;
	
	NSMutableArray	*renderebleObjectsArray;
}

@property	(readonly)	GLint	backingWidth;
@property	(readonly)	GLint	backingHeight;
@property	(readonly)	EAGLContext *glContext;
-(void)dealloc;

-(bool)initWithLayer:(CAEAGLLayer*) layer;

-(void)onFrameResize;

-(void) setClearColor:(ColorRGBA)color;

- (void)drawBegin;
- (void)drawEnd;

- (void) setCamera:(Camera*)camera;

- (void) setTexture:(Texture*)texture;

//- (void) pushTransform:(Transform*)transform;
//- (void) popTransform;

-(void) setVertexBuffer:(void*)buffer vertexComponentsCount:(int)size;

-(void) setNormalBuffer:(void*)buffer normalComponentsCount:(int)normalSize;
-(void) disableNormalBuffer;

-(void) setColorBuffer:(void*)buffer colorComponentsCount:(int)size;
-(void) disableColorBuffer;

-(void) setTexCoordBuffer:(void*)buffer texCoordComponentsCount:(int)coordCount;
-(void) disableTexCoordBuffer;

-(void) enableTextures;
-(void) disableTextures;

-(void) enableBlending;
-(void) disableBlending;

-(void) enableFaceCulling;
-(void) disableFaceCulling;

//-(void) enableLighting;
//-(void) disableLighting;
//-(void) disableLight:(int)num;
//-(void) setLight:(Light*)light num:(int)num;

-(void) setGlobalAmbientR:(float)r G:(float)g B:(float)b A:(float)a;

-(void) enableShading;
-(void) disableShading;
//-(void) setShadingMode:(ShadeMode)shadeMode;

-(void) drawPrimitive:(int)primitiveType vertexCount:(int)vertCount;
-(void) drawPrimitiveIndexed:(int)primitiveType primitiveCount:(int)vertexCount indexBuffer:(void*)indexBuffer;

- (void) drawTriStripBuffer:(void*)vertexBuffer vertCount:(int)vertCount;

-(void)onCameraChange;

-(void) drawRendereble:(Rendereble*) rendereble;
-(void) drawRenderebleObjects;

@end
